<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	template="/layout/layout.xhtml">

	<ui:define name="content">

		<h:form>
		      
		    <!-- <p:growl id="growl" />   -->
		    
		    <p:panel header="Lancement du batch" style="text-align: center; margin:10px; float:left; width:99%">       
			    <p:commandButton value="Commencer" ajax="true" onclick="pbAjax.start();startButton2.disable();" action="#{batchControler.start}" widgetVar="startButton2"/>
			    <p:commandButton value="Stopper" actionListener="#{batchControler.cancel}" oncomplete="pbAjax.cancel();startButton2.enable();" widgetVar=""/>
				
			    <p:progressBar widgetVar="pbAjax" ajax="true" value="#{batchControler.progress}" labelTemplate="{value}%" styleClass="animated" interval="1000">
			        <p:ajax event="complete" listener="#{batchControler.onComplete}" update="stepsTable" oncomplete="startButton2.enable()"/>
			    </p:progressBar>
			    
			    <br />
			    
			    <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
			    
			    <br />
			    
		        <p:dataTable id="stepsTable" var="stepExecution" value="#{batchControler.stepExecutions}" >
			        <p:column headerText="Nom">
			            <h:outputText value="Impoort des #{stepExecution.stepName}" />
			        </p:column>
			        <p:column headerText="Lignes lues">
			            <h:outputText value="#{stepExecution.readCount}" />
			        </p:column>
			
			        <p:column headerText="Lignes ecrites">
			            <h:outputText value="#{stepExecution.writeCount}" />
			        </p:column>
			        
         			<p:column headerText="Lignes non lues">
			            <h:outputText value="#{stepExecution.readSkipCount}" />
			        </p:column>
			        
      			    <p:column headerText="Lignes non ecrites">
			            <h:outputText value="#{stepExecution.writeSkipCount}" />
			        </p:column>
			
			        <p:column headerText="Statut">
			            <h:outputText value="#{stepExecution.exitStatus.exitCode}" />
			        </p:column>
			        
			        <p:column headerText="Dernier import">
			            <h:outputText value="#{stepExecution.lastUpdated}">
			            	<f:convertDateTime timeZone="GMT+1" pattern="dd/MM/yyyy HH:mm:ss" />
			            </h:outputText>
			        </p:column>
			
			    </p:dataTable>
			    
			</p:panel>
		</h:form>
		
	</ui:define>
</ui:composition>
